package com.cyzy.openfeign.impl;

import com.cyzy.dto.R;
import com.cyzy.openfeign.SaveControllerFeign;
import com.cyzy.vo.ExamAdmin;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SaveControllerFeignImpl implements SaveControllerFeign {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Override
    public R save(ExamAdmin examAdmin) {
        System.out.println("FallBack启动了");
        //                                           消息的主题        消息内容
        rocketMQTemplate.convertAndSend("exam-exercise", examAdmin);
        //同步发送，异步发送，单词发送
        //生产者
        //存入MQ  异步处理    等待：exam-save重启后，再读取mq的消息，再保存
        return R.ok().data("examAdmin", "我是FallBack");
    }
}
